/*!
 * \file frstr_new.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frstr.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    Frstr *p_frstr = NULL;

    p_frstr = frstr_new(0);

    CU_ASSERT_EQUAL(p_frstr->ui_allocated_size, 1);

    frstr_free(&p_frstr);

}

static void __case2(void)
{
    Frstr *p_frstr = NULL;

    p_frstr = frstr_new(2047);

    CU_ASSERT_EQUAL(p_frstr->ui_allocated_size, 4095);

    frstr_free(&p_frstr);

}

static void __case3(void)
{
    Frstr *p_frstr = NULL;

    p_frstr = frstr_new(2048);

    CU_ASSERT_EQUAL(p_frstr->ui_allocated_size, 4097);

    frstr_free(&p_frstr);

}

static void __case4(void)
{
    Frstr *p_frstr = NULL;

    p_frstr = frstr_new(2049);

    CU_ASSERT_EQUAL(p_frstr->ui_allocated_size, 2050);

    frstr_free(&p_frstr);

}

int add_suite_frstr_new(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frstr frstr_new()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);

    return FR_SUCC;
}
